# -*- coding: utf-8 -*-

class File:
    def read(self):
        print(self.path)
#实例化一个File类对象
obj = File()
#在对象中写一个path='hello'
obj.path = 'hello'
#通过对象调用类中的read方法,read方法中的self就是obj

class Person:
    def __init__(self):
        self.name = 'jack'
        self.age = 23
        self.gender = '男'
    def show(self):
        temp = '我是%s,年龄%s,性别%s'%(self.name,self.age,self.gender)
        print(temp)
p1 = Person()
p1.show()



def print_user():
    user_list = []
    while True:
        user = input('请输入用户名：')
        pwd = input('请输入密码：')
        email = input('请输入邮箱')
        temp = {'username':user,'password':pwd,'email':email}
        user_list.append(temp)
    for item in user_list:
        temp = '我的名字:%s,密码%s,邮箱%s' % (item['username'],item['password'],item['email'])
        print(temp)

        
#面向对象写法
class User:
    def __init__(self,user,pwd,email):
        self.username = user
        self.password = pwd
        self.email = email
    
    def info(self):
        return '我的名字:%s,密码%s,邮箱%s' % (self.uername,self.password,self.email)

def main():
    user_list = []
    while True:
        user = input('请输入用户名：')
        pwd = input('请输入密码：')
        email = input('请输入邮箱')
        p = User(user, pwd, email)
        user_list.append(p)
    for item in user_list:
        print(item.info())
        
class Police:
    def __init__(self,name):
        self.name = name
        self.hp = 10000
        
    def dao(self,other):
        msg = '%s给了%s一刀' % (self.name,other.nickname)
        self.hp = self.hp -10
        other.hp = other.hp - 50
        print(msg)
        
    def qiang(self,other):
        msg = '%s给了%s一枪' % (self.name,other)
        self.hp = self.hp - 5
        other.hp = other.hp - 100
        print(msg)
    
    def quan(self,other):
        msg = '%s给了%s一拳' % (self.name,other)
        self.hp = self.hp - 5
        other.hp = other.hp - 20
        print(msg)
        
wmz = Police('王麻子')

class Bandit:
    def __init__(self,nickname):
        self.nickname = nickname
        self.hp = 1000
    
    def dao(self,other):
        msg = '%s给了%s一刀' % (self.nickname,other)
        self.hp = self.hp -10
        other.hp = other.hp - 50
        print(msg)
        
    def qiang(self,other):
        msg = '%s给了%s一枪' % (self.nickname,other)
        self.hp = self.hp - 5
        other.hp = other.hp - 100
        print(msg)
    
    def quan(self,other):
        msg = '%s给了%s一拳' % (self.nickname,other)
        self.hp = self.hp - 5
        other.hp = other.hp - 20
        print(msg)
        
eg = Bandit('二蛋')
lp = Bandit('二狗')

#二狗去谋杀王麻子,二狗-100，王麻子-500
lp.dao(wmz)
wmz.qiang(lp)
